<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
    <head>
        <title>Updatable Collections</title>
    </head>
    
    <body>
        <table border="0">
            <form method="post">
                <tr bgcolor="blue">
                    <td>
                        <p align="center">
                            <b>
                                <font color="#FFFFFF">Parse for Tokens</font>
                            </b>
                        </p>
                    </td>
                </tr>
                
                <tr>
                    <td valign="top">
                        <p align="left">Enter a sentence:
                            <br />
                            
                            <input width="20" maxwidth="20" name="text"
                                   size="50" />
                            
                            <br />
                            
                        &#160;</p>
                    </td>
                </tr>
                
                <tr>
                    <td valign="top">
                        <p align="center">
                            <input type="submit" name="parse" value="Parse" />
                        </p>
                    </td>
                </tr>
            </form>
        </table>
        
        <c:if test="${pageContext.request.method=='POST'}">
            <table border="1">
                <c:set var="i" value="1" />
                <c:forTokens items="${param.text}" var="word"
                             delims=" ,.?!">
                    <c:set var="i" value="${i}" />
                    
                    <tr>
                        <td>
                            <b>Word 
                                <c:out value="${i}" />
                            </b>
                        </td>
                        
                        <td>
                            <c:out value="${word}" />
                        </td>
                    </tr>
                </c:forTokens>
            </table>
        </c:if>
    </body>
</html>

